package com.util;


//使用 char2int 方法将字符数组转换回整数
public class Char2intUnit {
    public static int char2int(byte[] source,int mlen) {
        if (source.length < 4) {
            throw new IllegalArgumentException("Source array must have at least 4 bytes.");
        }
        return ((source[0] & 0xFF) << 24) |
                ((source[1] & 0xFF) << 16) |
                ((source[2] & 0xFF) << 8) |
                (source[3] & 0xFF);
    }

    public static void main(String[] args) {
        byte[] source = {0x01, 0x02, 0x03, 0x04};
        int result = char2int(source,4);
        System.out.println("Result: " + result);  // 输出结果
    }
}
